package de.idgard.android.addon.services.transport;

import org.apache.http.cookie.Cookie;

import de.idgard.android.addon.services.GlobalServiceRegistry;
import de.idgard.json.transport.IDGHttpClient;

/**
 * 
 * @author <a href="mailto:vesko.georgiev@uniscon.com">Vesko Georgiev</a>
 */
public class AndroidHttpClient extends IDGHttpClient {

	public AndroidHttpClient(String idgardHost) {
		super(idgardHost);
	}

	@Override
	public void onPreExecute() {
		getCookieStore().clear();
		Cookie[] cookies = GlobalServiceRegistry.instance().getBrowserUtilityService().getIdgardCookies();

		if (cookies == null) {
			return;
		}
		
		for (Cookie c : cookies) {
			getCookieStore().addCookie(c);
		}
	}

}
